<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
    <script type="text/javascript" src="/js/jquery-1.11.1.js"></script>
</head>
<body>
    <h3>welcome to shared electrombile management system.</h3>

    <div class="login-form">
        <input type="text" class="text uname" name="uname" placeholder="用户名" />
        <input type="password" class="text password" name="password" placeholder="密码不少于六位" />
        <input type="button" value="登录" class="login">
    </div>
    <hr/>
    result:<span id="result"></span>
</body>
<script type="text/javascript">
    $(function () {
        /*$(location).attr('href', '//127.0.0.1:8080/index.html');*/
        $(".login").click(function () {
            var uname = $(".uname").val();
            var password = $(".password").val();
            console.log("uname==>>" + uname);
            console.log("password==>>" + password);
            $.ajax({
                type: "post",
                url: "/user/login",
                contentType:"application/json;charset=utf-8",
                data:'{"uname":"' + uname +'","password":"' + password + '"}',
                dataType:"json",
                success:function(item, state) {
                    console.log("响应成功");
                    $("#result").text(JSON.stringify(item));
                    console.log("state==>" + state);
                    /*$(location).attr('href', '//127.0.0.1:8080/admin.html?');*/
                } ,
                error:function() {
                    console.log("响应失败");
                }
            });
        });
    });
</script>
</html>